﻿using System;
using System.Collections.Generic;
using System.Web.UI;
using Evpo.ContactData.UI.GeneralClasses;

namespace Evpo.ContactData.UI.Tools
{
    public class ItemInListContainer
    {
        #region Fields
        #endregion

        #region Properties
        #endregion

        #region Methods
        internal IEnumerable<int> SelectedItems(IEnumerable<Control> Controls, string itemInListName)
        {
            foreach (Control cnt in Controls)
            {
                ItemInList itemInList = (ItemInList)cnt.FindControl(itemInListName);
                if (itemInList == null)
                {
                    throw new ApplicationException(itemInListName + " is not found");
                }

                if (!itemInList.IsSelected)
                    continue;
                yield return itemInList.ItemID;
            }
        }

        #endregion Methods
    }
}
